// 添加material依赖
import 'package:flutter/material.dart';
import 'package:flutter_application_2/routes.dart';

// 编写无状态组件
class PageContent extends StatelessWidget {
  // 添加name参数
  final String name;

  const PageContent({Key key, this.name}) : super(key: key);

  Widget build(BuildContext context) {
    // 使用scaffold组件
    return Scaffold(
      appBar: AppBar(
        title: Text(name),
      ),
      body: ListView(
        children: [
          TextButton(
            onPressed: () {
              Navigator.pushNamed(context, Routes.home);
            },
            child: Text(
              Routes.home,
              style: TextStyle(color: Colors.red),
            ),
          ),
          TextButton(
            onPressed: () {
              Navigator.pushNamed(context, Routes.login);
            },
            child: Text(Routes.login),
          ),
          TextButton(
            onPressed: () {
              Navigator.pushNamed(context, 'Routes.login');
            },
            child: Text('不存在的页面'),
          ),
          TextButton(
            onPressed: () {
              Navigator.pushNamed(context, '/room/222');
            },
            child: Text('带参数的页面'),
          ),
        ],
      ),
    );
  }
}
